package com.selfdriving.dialog;

import com.selfdriving.R;
import android.app.Dialog;
import android.content.Context;
import android.widget.Button;
import android.widget.TextView;
import android.view.View;

public class MessageDialog extends Dialog {
	private Context context;

	private String title;

	private String message;
	
	private String sureStr;
	
	private String cancelStr;

	private boolean sure;

	private boolean cancel;
	
	private android.view.View.OnClickListener onClickListener;

	public MessageDialog(Context context, String title, String message,String sureStr,String cancelStr,
			boolean sure, boolean cancel,android.view.View.OnClickListener onClickListener) {
		super(context, R.style.dialog);
		this.title = title;
		this.message = message;
		this.sure = sure;
		this.cancel = cancel;
		this.sureStr =sureStr;
		this.cancelStr =cancelStr;
		this.onClickListener =onClickListener;
		// 获得弹出窗口的布局
		this.context = context;
		setContentView(R.layout.common_dialog_generic);
		init();
	}

	private void init() {
		TextView tvTitle = (TextView) findViewById(R.id.dialog_generic_htv_title);
		TextView tvMessage = (TextView) findViewById(R.id.dialog_generic_htv_message);
		Button button1 = (Button) findViewById(R.id.dialog_generic_btn_button1);
		Button button2 = (Button) findViewById(R.id.dialog_generic_btn_button2);
		Button button3 = (Button) findViewById(R.id.dialog_generic_btn_button3);
		button1.setOnClickListener(onClickListener);
		button2.setOnClickListener(onClickListener);
		tvTitle.setText(title);
		tvMessage.setText(message);
		if (sure) {
			button1.setText(sureStr);
			button1.setVisibility(View.VISIBLE);
		}
		if (cancel) {
			button2.setVisibility(View.VISIBLE);
			button2.setText(cancelStr);
		}

	}

}
